package com.pds.web.operationLog.controller;

import com.pds.common.core.controller.BaseController;
import com.pds.common.core.domain.R;
import com.pds.common.core.page.TableDataInfo;
import com.pds.web.operationLog.entity.PdsOperationLog;
import com.pds.web.operationLog.service.PdsOperationLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * 用户业务操作日志表
 *
 * @author srf sunlightcs@gmail.com
 * @since 1.0.0 2024-02-07
 */
@RestController
@RequestMapping("/operationLog")
@Api(tags="用户操作日志")
public class PdsOperationLogController extends BaseController{
    @Resource
    private PdsOperationLogService pdsOperationLogService;

    /**
     * 分页查询操作日志
     *
     *   pageNum/pageSize分页字段
     *   筛选条件字段
     * @return 查询结果
     */
    @ApiOperation("分页查询操作日志")
    @GetMapping("/page")
    public TableDataInfo pageEnvironmentExamine(PdsOperationLog pdsOperationLog){
        startPage();
        List<PdsOperationLog> list = pdsOperationLogService.selectList(pdsOperationLog);
        return getDataTable(list);
    }

    /**
     * 创建操作日志
     * @param pdsOperationLog 记录
     * @return 操作日志
     */
    @ApiOperation("创建操作日志")
    @PostMapping("/add")
    public R<PdsOperationLog> addEnvironmentExamine(@RequestBody PdsOperationLog pdsOperationLog){
        return R.ok(pdsOperationLogService.insert(pdsOperationLog));
    }

    /**
     * 根据ID删除抽查记录
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @ApiOperation("删除抽查记录")
    @DeleteMapping("/delete")
    public R<Boolean> deleteEnvironmentExamineById(@RequestParam Long id) {
        return R.ok(pdsOperationLogService.deleteById(id));
    }
}